https://songlee24.github.io/2014/04/09/matrix-transpose-inplace/